﻿
Imports System.IO
Imports std
Imports xmlctrl
Imports xhtmlctrl
Imports webctrl

Public Class homepage
    Inherits cacheProcessor

    Public Const _pathidentity As String = "/"

    Public Overrides Function pathidentity() As String
        Return _pathidentity
    End Function

    Public Overrides Function pathidentitylen() As Long
        Return strlen(pathidentity())
    End Function

    Protected Overrides Function retiredticks() As Long
        Return -1
    End Function

    Protected Overrides Function processImpl(ByVal context As httpContext) As Boolean
        Dim buff As MemoryStream = Nothing
        buff = context.buff()

        Dim page As xhtmlpage = Nothing
        page = New xhtmlpage(buff)
        page.title().text = applicationSign()
        page.body().id = "id_home"

        Dim csslink As csslink = Nothing
        csslink = New csslink(buff)
        csslink.href = csslinkhref
        page.head().addchild(csslink)
        iframeJumpKeeper.invoke(page)

        Dim rails As table = Nothing
        rails = New table(buff)
        rails.id = "id_rails"
        page.body().addchild(rails)

        Dim leftrail As td = Nothing
        leftrail = New td(buff)
        leftrail.id = "id_leftrail"
        rails.addchild(leftrail)

        Dim rightrail As td = Nothing
        rightrail = New td(buff)
        rightrail.id = "id_rightrail"
        rails.addchild(rightrail)

        Dim iframe As autoheightIframe = Nothing
        iframe = New autoheightIframe(buff, page.inlineScript())
        iframe.src = strmid(aboutme._pathidentity, strlen(network.pathSeperator))
        iframe.frameborder = 0
        iframe.marginheight = 0
        iframe.marginwidth = 0
        leftrail.addchild(iframe)

        iframe = New autoheightIframe(buff, page.inlineScript())
        iframe.src = strmid(counter._pathidentity, strlen(network.pathSeperator)) + _
                     network.pathSeperator + homeserveCounterKey
        iframe.frameborder = 0
        iframe.marginheight = 0
        iframe.marginwidth = 0
        leftrail.addchild(iframe)

        iframe = New autoheightIframe(buff, page.inlineScript())
        iframe.src = strmid(links._pathidentity, strlen(network.pathSeperator)) + network.questionMark _
                    + links.countquery + network.argumentNameValueSeperator _
                    + Convert.ToString(config.parameter(configNaming.links.name, configNaming.links.linkcount _
                                                         , configNaming.defaultValue.links.linkcount))
        iframe.frameborder = 0
        iframe.marginheight = 0
        iframe.marginwidth = 0
        leftrail.addchild(iframe)

        iframe = New autoheightIframe(buff, page.inlineScript())
        iframe.src = strmid(image._pathidentity, strlen(network.pathSeperator))
        iframe.frameborder = 0
        iframe.marginheight = 0
        iframe.marginwidth = 0
        leftrail.addchild(iframe)

        iframe = New autoheightIframe(buff, page.inlineScript())
        iframe.src = strmid(music._pathidentity, strlen(network.pathSeperator))
        iframe.frameborder = 0
        iframe.marginheight = 0
        iframe.marginwidth = 0
        leftrail.addchild(iframe)

        iframe = New autoheightIframe(buff, page.inlineScript())
        iframe.src = strmid(products._pathidentity, strlen(network.pathSeperator)) _
                    + urlUtils.combineQuery(products.countquery, Convert.ToString( _
                                            config.parameter(configNaming.products.name _
                                                             , configNaming.products.productcount _
                                                             , configNaming.defaultValue.products.productcount)))
        iframe.frameborder = 0
        iframe.marginheight = 0
        iframe.marginwidth = 0
        rightrail.addchild(iframe)

        iframe = New autoheightIframe(buff, page.inlineScript())
        iframe.src = strmid(blog._pathidentity, strlen(network.pathSeperator))
        iframe.frameborder = 0
        iframe.marginheight = 0
        iframe.marginwidth = 0
        rightrail.addchild(iframe)

        iframe = New autoheightIframe(buff, page.inlineScript())
        iframe.src = strmid(comment._pathidentity, strlen(network.pathSeperator)) + network.questionMark _
                        + comment.keyquery + network.argumentNameValueSeperator + "homeserve_comment"
        iframe.frameborder = 0
        iframe.marginheight = 0
        iframe.marginwidth = 0
        rightrail.addchild(iframe)

        If page.render() Then
            Return True
        Else
            raiseError("cannot render xhtmlpage.", errorHandle.errorType.warning)
            Return False
        End If
    End Function
End Class
